<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>主讲人管理</title>

    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/confirm.js"></script>
	<script src="${pageContext.request.contextPath}/js/jquery.validate.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/message_cn.js"></script>
	<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
	
	<script type="text/javascript">
	
	
    	function showAddVideo(){
    	location.href="addSpeakerView.action";
    	}
	
	
		function ajaxDelete(obj,id,speakerName){
  		Confirm.show('温馨提示', '确认删除'+speakerName+'么？', {
  			'Delete':{
  				'primary':true,
  				'callback':function(){
  					var params = {"id":id};
  					$.post("deleteSpeaker.action",params,function(data){
  						if(data=='success'){
                            $(obj).parent().parent().remove();
                            Confirm.show('处理结果', '成功删除');
                         }else{
                              Confirm.show('处理结果', '删除失败');
                         }
  					});
  				}
  			}
  		
  		});
  	}
	</script>
	
  </head>
  
  <style type="text/css">
		.table th { 
			text-align: center;
			vertical-align: middle;
			font-size: 14px;
			font-weight: 700;
		}
	</style>
  <body>
    
    <nav class="navbar navbar-inverse" style="margin-bottom:0px;">
     <div class="container">
     
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          
          <a class="navbar-brand" href="videoList.action">视频管理项目</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9">
          <ul class="nav navbar-nav">
            <li ><a href="videoList.action">视频管理</a></li>
            <li class="active"><a href="speakerList.action">主讲人管理</a></li>
            <li><a href="courseList.action">课程管理</a></li>
          </ul>
          
          <p class="navbar-text navbar-right"><span>admin</span><i class="glyphicon glyphicon-log-in"></i>
            <a href="${pageContext.request.contextPath}/admin/exit.action" class="navbar-link">退出</a>
          </p>
        </div><!-- /.navbar-collapse -->
       </div>
      </div><!-- /.container-fluid -->
    </nav>
    <div class="jumbotron" style="margin-top:0px;padding-top:7px;padding-bottom:7px;">
	    <div class="container" >
	       <h2>主讲人管理</h2>
	    </div>
	</div>
	
	<div class="container">
	     <button  type="button" onclick="showAddVideo()"
					class="btn btn-info dropdown-toggle" data-toggle="dropdown"
					aria-haspopup="true" aria-expanded="false">添加</button>
	</div>
	
	<div class="container" style="margin-top:20px;">
	    <table class="table table-bordered table-hover" style="text-align:center;">
		      <thead>
		        <tr class="active">
		          <th width="10%">序号</th>
		          <th width="10%">名称</th>
		          <th width="10%">职位</th>
		          <th>简介</th>
		          <th width="10%">编辑</th>
		          <th width="10%">删除</th>
		        </tr>
		      </thead>
		      <tbody>
		        <c:forEach items="${allSpeaker }" var="speaker" varStatus="statu">
		        	<tr>
			          <td>${statu.count }</td>
			          <td>${speaker.speakerName }</td>
			          <td>${speaker.speakerJob }</td>
			          <td>${speaker.speakerDesc }</td>
			          <td><a href="editSpeaker.action?id=${speaker.id }"><span class="glyphicon glyphicon-edit"></span></a></td>
			          <td><a href="javascript:void(0);" onclick="ajaxDelete(this,'${speaker.id}','${speaker.speakerName}')">
			          <span class="glyphicon glyphicon-trash"></span></a></td>
			        </tr>
		        
		        
		        </c:forEach>
		        
		      </tbody>
		    </table>
	</div>
  </body>
  
  
</html>